package org.proddevplm.business.openRoom;

import java.util.HashMap;
import java.util.Map;

import org.proddevplm.business.api.IAdapter;
import org.proddevplm.business.openRoom.constants.OpenRoomConstants;
import org.proddevplm.business.product.constants.ProductConstants;
import org.proddevplm.helpers.ManagerUtil;

public class OpenRoomAdapter implements IAdapter{

	Object adaptedObject = null;
	Map<String, Object> openRoomMap = new HashMap<String, Object>();
	
	@Override
	public Object adapt(int command, Map<String, Object> dataObject) {
		openRoomMap.clear();
		System.out.println(command);
		switch (command){
		case OpenRoomConstants.CHAT:
			openRoomMap.put("userMessage", ManagerUtil.getStringFromReq(dataObject.get("userMessage")));
			if (dataObject.containsKey("roomName"))
				openRoomMap.put("roomName", ManagerUtil.getStringFromReq(dataObject.get("roomName")));
			else
				openRoomMap.put("roomName", "default");
			break;
		
		case OpenRoomConstants.GET_ALL_MESSAGES:
			openRoomMap.put("getFrom", ManagerUtil.getStringFromReq(dataObject.get("getFromIndex")));
			if (dataObject.containsKey("roomName"))
				openRoomMap.put("roomName", ManagerUtil.getStringFromReq(dataObject.get("roomName")));
			break;
		}
		
		adaptedObject = openRoomMap;
		return adaptedObject;
		
	}
}
